<?php
class Public_Controller extends Controller
{
	
	public $department = NULL;
	
	function __construct()
	{
		parent::__construct();	
		
		// check login
		//if(!is_login()) redirect('member/login/?a=1');
		
		// set theme
		$this->template->set_theme('fund');
		
		// set layout
		$this->template->set_layout('layout');
		
		// set title
		$this->template->title('โปรแกรมระบบบัญชีเงินกองทุน');
		
		// Set js
		$this->template->append_metadata(js_notify());
		
		// set user department
		//$this->department = login_data('dpc_id');
		$this->lang->load('admin');
	}
	
	function captcha()
	{
		$this->load->library('captcha');
		$captcha = new Captcha();
		$captcha->size = 4;
		$captcha->chars = '0123456789';
		$captcha->session = "captcha";
		$captcha->display();
	}
	
	function is_access_department($table,$id = FALSE)
	{
		if($id && $this->department != CENTRE)
		{
			$var = $this->db->getone("select id from $table where id = ? and dpc_id = ?",array($id,$this->department));
			return ($var);
		}
		return TRUE;
	}
	
}
?>